package com.autumn.domain.repositories.plugins;

import com.autumn.mybatis.mapper.IEntityMapper;

/**
 * 审计方法类型
 * 
 * @author 老码农
 *
 *         2017-12-11 17:30:33
 */
public enum AuditingMethodEnum {

	/**
	 * 未知
	 */
	UN_KNOWN("unknown"),

	/**
	 * 插入
	 */
	INSERT(IEntityMapper.INSERT),

	/**
	 * 批量插入
	 */
	BATCH_INSERT(IEntityMapper.BATCH_INSERT),

	/**
	 * 全部更新
	 */
	UPDATE(IEntityMapper.UPDATE),

	/**
	 * 非 null 更新
	 */
	UPDATE_NOT_NULL(IEntityMapper.UPDATE_NOT_NULL),

	/**
	 * 指定部份更新
	 */
	UPDATE_BY_SPECIFY(IEntityMapper.UPDATE_BY_SPECIFY),

	/**
	 * 基于主键删除
	 */
	DELETE_BY_PRIMARY_KEY(IEntityMapper.DELETE_BY_PRIMARY_KEY),

	/**
	 * 基于条件删除
	 */
	DELETE_BY_WHERE(IEntityMapper.DELETE_BY_WHERE),

	/**
	 * 基于主键查询
	 */
	GET(IEntityMapper.GET),

	/**
	 * 基于主键加锁查询
	 */
	GET_BY_LOCK(IEntityMapper.GET_BY_LOCK),

	/**
	 * 查询实体首条记录
	 */
	SELECT_FIRST(IEntityMapper.SELECT_FIRST),

	/**
	 * 查符合条件的首条件
	 */
	SELECT_BY_SPECIFY_FIRST(IEntityMapper.SELECT_BY_SPECIFY_FIRST),

	/**
	 * 指定查询
	 */
	SELECT_BY_SPECIFY(IEntityMapper.SELECT_BY_SPECIFY),

	/**
	 * 查询所有
	 */
	SELECT_ALL(IEntityMapper.SELECT_ALL),

	/**
	 * 查询所有(锁)
	 */
	SELECT_ALL_BY_LOCK(IEntityMapper.SELECT_ALL_BY_LOCK),

	/**
	 * 查询得到list集合
	 */
	SELECT_LIST(IEntityMapper.SELECT_LIST),

	/**
	 * 查询所有记录数
	 */
	COUNT(IEntityMapper.COUNT),

	/**
	 * 统计所有记录数(锁)
	 */
	COUNT_BY_LOCK(IEntityMapper.COUNT_BY_LOCK),

	/**
	 * 根据条件查询记录数
	 */
	COUNT_BY_WHERE(IEntityMapper.COUNT_BY_WHERE);

	private final String methodName;

	private AuditingMethodEnum(String methodName) {
		this.methodName = methodName;
	}

	/**
	 * 获取方法名称
	 * 
	 * @return 2017-12-11 17:38:42
	 */
	public String getMethodName() {
		return methodName;
	}

	/**
	 * 
	 * @param name
	 * @return 2017-12-11 21:00:03
	 */
	public static AuditingMethodEnum forName(String name) {
		for (AuditingMethodEnum ame : values()) {
			if (ame.getMethodName().equals(name)) {
				return ame;
			}
		}
		return null;
	}

}
